package com.shen.accountbook.bean.temp;

import android.os.Parcel;
import android.os.Parcelable;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Keep;
import org.greenrobot.greendao.annotation.NotNull;
import org.greenrobot.greendao.annotation.ToOne;
import org.greenrobot.greendao.annotation.Transient;
import org.greenrobot.greendao.annotation.Unique;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.DaoException;
import com.shen.accountbook.greendao.DaoSession;
import com.shen.accountbook.greendao.SecondSortBeanDao;
import com.shen.accountbook.greendao.ThirdSortBeanDao;

import java.util.List;

@Entity
public class ThirdSortBean implements Parcelable {
    /**
     * sort_id : 301
     * uid : 0
     * sort_name : 偿还费用
     * sort_img : /UF/Uploads/Noteimg/blacksort/changhuanfeiyong@2x.png
     */

	@Id
    private Long id;

    /** 一级分类的ID */
    @NotNull
    private Long first_sort_id;
    /** 二级分类的ID */
    @NotNull
    private Long second_sort_id;
    @ToOne(joinProperty = "second_sort_id")
    private SecondSortBean secondSortBean;


    /** 三级分类的ID */
    @Unique
    private Long third_sort_id;

    /** 三级分类的名称 */
    private String third_sort_name;
    /** 三级分类的图片 */
    private String third_sort_img;

    /** 使用的频率 */
    private Long frequency;

    /** Used to resolve relations */
    @Generated(hash = 2040040024)
    private transient DaoSession daoSession;


    /** Used for active entity operations. */
    @Generated(hash = 965777005)
    private transient ThirdSortBeanDao myDao;






    @Generated(hash = 880442945)
    public ThirdSortBean(Long id, @NotNull Long first_sort_id, @NotNull Long second_sort_id,
            Long third_sort_id, String third_sort_name, String third_sort_img,
            Long frequency) {
        this.id = id;
        this.first_sort_id = first_sort_id;
        this.second_sort_id = second_sort_id;
        this.third_sort_id = third_sort_id;
        this.third_sort_name = third_sort_name;
        this.third_sort_img = third_sort_img;
        this.frequency = frequency;
    }

    @Generated(hash = 2107807914)
    public ThirdSortBean() {
    }

    @Generated(hash = 947523600)
    private transient Long secondSortBean__resolvedKey;






    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }


    public Long getSecond_sort_id() {
        return second_sort_id;
    }

    public void setSecond_sort_id(Long second_sort_id) {
        this.second_sort_id = second_sort_id;
    }


    public Long getThird_sort_id() {
        return third_sort_id;
    }

    public void setThird_sort_id(Long third_sort_id) {
        this.third_sort_id = third_sort_id;
    }

    public String getThird_sort_name() {
        return third_sort_name;
    }

    public void setThird_sort_name(String third_sort_name) {
        this.third_sort_name = third_sort_name;
    }

    public String getThird_sort_img() {
        return third_sort_img;
    }

    public void setThird_sort_img(String third_sort_img) {
        this.third_sort_img = third_sort_img;
    }


    /** To-one relationship, resolved on first access. */
    @Generated(hash = 2089528114)
    @Keep
    public SecondSortBean getSecondSortBean() {
        Long __key = this.second_sort_id;
        if (secondSortBean__resolvedKey == null
                || !secondSortBean__resolvedKey.equals(__key)) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            SecondSortBeanDao targetDao = daoSession.getSecondSortBeanDao();
            SecondSortBean secondSortBeanNew = null;
            List<SecondSortBean> list = targetDao.queryBuilder()
                    .where(SecondSortBeanDao.Properties.Second_sort_id.eq(__key)).list();

            if(list != null && list.size() > 0){
                secondSortBeanNew = list.get(0);
            }
            synchronized (this) {
                secondSortBean = secondSortBeanNew;
                secondSortBean__resolvedKey = __key;
            }
        }
        return secondSortBean;
    }

    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 255167402)
    public void setSecondSortBean(@NotNull SecondSortBean secondSortBean) {
        if (secondSortBean == null) {
            throw new DaoException(
                    "To-one property 'second_sort_id' has not-null constraint; cannot set to-one to null");
        }
        synchronized (this) {
            this.secondSortBean = secondSortBean;
            second_sort_id = secondSortBean.getId();
            secondSortBean__resolvedKey = second_sort_id;
        }
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 128553479)
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 1942392019)
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 713229351)
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }

    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 1975961047)
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getThirdSortBeanDao() : null;
    }

    public Long getFrequency() {
        return this.frequency;
    }

    public void setFrequency(Long frequency) {
        this.frequency = frequency;
    }

    public Long getFirst_sort_id() {
        return this.first_sort_id;
    }

    public void setFirst_sort_id(Long first_sort_id) {
        this.first_sort_id = first_sort_id;
    }


    @Override
    public String toString() {
        return "ThirdSortBean{" +
                "id=" + id +
                ", first_sort_id=" + first_sort_id +
                ", second_sort_id=" + second_sort_id +
                ", secondSortBean=" + secondSortBean +
                ", third_sort_id=" + third_sort_id +
                ", third_sort_name='" + third_sort_name + '\'' +
                ", third_sort_img='" + third_sort_img + '\'' +
                ", frequency=" + frequency +
                ", daoSession=" + daoSession +
                ", myDao=" + myDao +
                ", secondSortBean__resolvedKey=" + secondSortBean__resolvedKey +
                '}';
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeValue(this.id);
        dest.writeValue(this.first_sort_id);
        dest.writeValue(this.second_sort_id);
        dest.writeParcelable(this.secondSortBean, flags);
        dest.writeValue(this.third_sort_id);
        dest.writeString(this.third_sort_name);
        dest.writeString(this.third_sort_img);
        dest.writeValue(this.frequency);
    }

    protected ThirdSortBean(Parcel in) {
        this.id = (Long) in.readValue(Long.class.getClassLoader());
        this.first_sort_id = (Long) in.readValue(Long.class.getClassLoader());
        this.second_sort_id = (Long) in.readValue(Long.class.getClassLoader());
        this.secondSortBean = in.readParcelable(SecondSortBean.class.getClassLoader());
        this.third_sort_id = (Long) in.readValue(Long.class.getClassLoader());
        this.third_sort_name = in.readString();
        this.third_sort_img = in.readString();
        this.frequency = (Long) in.readValue(Long.class.getClassLoader());
    }

    public static final Parcelable.Creator<ThirdSortBean> CREATOR = new Parcelable.Creator<ThirdSortBean>() {
        @Override
        public ThirdSortBean createFromParcel(Parcel source) {
            return new ThirdSortBean(source);
        }

        @Override
        public ThirdSortBean[] newArray(int size) {
            return new ThirdSortBean[size];
        }
    };
}